<include file="public@head" />
</head>

<body>
    <div class="layui-fluid wrap js-check-wrap" id="component-tabs">
        <div class="layui-row">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">导航管理</div>
                    <div class="layui-card-body">
                        <div class="layui-tab">
                            <ul class="layui-tab-title">
                                <li><a href="{:url('NavMenu/index',['nav_id'=>$nav_id])}">导航菜单</a></li>
                                <li class="layui-this"><a>{:lang('ADMIN_MENU_ADD')}</a></li>
                            </ul>
                            <div class="layui-tab-content">
                                <div class="layui-tab-item layui-show">
                                    <form method="post" class="layui-form js-ajax-form" action="{:url('NavMenu/addPost')}">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">上级:</label>
                                            <div class="layui-input-block">
                                                <select name="parent_id">
                                                    <option value="0">/</option>
                                                    {$nav_trees}
                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label"><span style="color:#FF5722;">*</span>地址:</label>
                                            <div class="layui-input-block">
                                                <div class="layui-inline">
                                                    <input type="radio" id="external-link-radio" class="layui-input-inline">
                                                </div>
                                                <div class="layui-inline">
                                                    <input type="text" class="layui-input layui-input-inline" name="href" id="external-link-input">
                                                </div>
                                                <div class="layui-inline">
                                                    <input type="radio" id="select-href-radio" class="layui-input-inline">
                                                </div>
                                                <div class="layui-inline">
                                                    <select name="href" id="select-href" class="layui-input-inline">
                                                        <option value="{:base64_encode('home')}" data-name="首页">首页</option>
                                                        <foreach name="navs" item="vo">
                                                            <optgroup label="{$vo.name}">
                                                                {$vo.html}
                                                            </optgroup>
                                                        </foreach>
                                                    </select>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label"><span style="color:#FF5722;">*</span>菜单名称:</label>
                                            <div class="layui-input-block">
                                                <input type="text" class="layui-input" name="name" id="name-input">
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">打开方式:</label>
                                            <div class="layui-input-block">
                                                <select name="target">
                                                    <option value="">默认方式</option>
                                                    <option value="_blank">新窗口打开</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">图标:</label>
                                            <div class="layui-input-block">
                                                <input type="text" class="layui-input" name="icon" value="">
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">显示:</label>
                                            <div class="layui-input-block">
                                                <select name="status">
                                                    <option value="1">显示</option>
                                                    <option value="0">隐藏</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-form-item layui-layout-admin">
                                            <div class="layui-input-block">
                                                <div class="layui-footer" style="left:0;">
                                                    <input type="hidden" name="nav_id" value="{$nav_id}" />
                                                    <button type="submit" class="layui-btn js-ajax-submit">{:lang("SAVE")}</button>
                                                    <a class="layui-btn layui-btn-primary" href="{:url('NavMenu/index',['nav_id'=>$nav_id])}">返回</a>
                                                </div>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <include file="public@footer" />
    <script>
    $(function() {
        $("#select-href,#select-href-radio").click(function() {
            checkChange(2);
        });

        $("#select-href").change(function() {
            var $this = $(this);
            var label = $this.find("option[value='" + $this.val() + "']").data('name');
            $('#name-input').val(label);
        });

        $("#external-link-input,#external-link-radio").click(function() {
            checkChange(1);
        });

        function checkChange(i) {
            if (i == 1) {
                //自动输入url
                $('#external-link-input').attr('name', 'external_href');
                $('#select-href').removeAttr('name');
                $('#select-href-radio').prop('checked', false);
                $('#external-link-radio').prop('checked', true);
            } else {
                //选择链接url
                $('#select-href').attr('name', 'href');
                $('#external-link-input').removeAttr('name');
                $('#select-href-radio').prop('checked', true);
                $('#external-link-radio').prop('checked', false);
            }
        }
    });
    </script>
</body>

</html>